package org.hry.netty.protobuf;


import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.protobuf.ProtobufDecoder;
import io.netty.handler.codec.protobuf.ProtobufEncoder;
import io.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder;
import io.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender;


/**
 * @Desc
 * @Author houry
 * @Date 2021/2/20 15:36
 **/
public class ProtoBufServerInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        ChannelPipeline pipeline = socketChannel.pipeline();
        pipeline.addLast(new TestByteToMessage());
        pipeline.addLast("protobufVarint32FrameDecoder", new ProtobufVarint32FrameDecoder());

        pipeline.addLast("protobufDecoder1", new ProtobufDecoder(BarrageProto.Barrage.getDefaultInstance()));
        pipeline.addLast("protobufVarint32LengthFieldPrepender", new ProtobufVarint32LengthFieldPrepender());
        pipeline.addLast("protobufEncoder", new ProtobufEncoder());
//        pipeline.addLast(new LJServerHandler());
        pipeline.addLast(new ProtoBufServerHandler());
        pipeline.addLast(new ProtoBufTestServerHandler());
        pipeline.addLast(new ProtoBufServerHandler());


    }
}
